package jay.home.bet.web.struts;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jay.home.bet.domain.Event;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class ListDanshiEventAction extends BaseAction
{
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception
	{
		List<Event> events;

		HashMap hashMap = new HashMap();

		hashMap.put("alive", true);
		hashMap.put("frozen", false);
		hashMap.put("published", true);
		hashMap.put("type", "单式");
		String leagueId = request.getParameter("leagueName");

		if (leagueId != null && !leagueId.equals("") && !leagueId.equals("all"))
		{
			hashMap.put("leagueid", leagueId);
			request.setAttribute("leagueId", leagueId);
		}
		int count = getOddsService().countEvents(hashMap);
		count = count / 50;
		events = getOddsService()
				.getEvents(hashMap, getPageNumber(request), 50);

		request.setAttribute("count", count);
		request.setAttribute("events", events);
		return mapping.findForward("SUCCESS");
	}
}
